using System;
using System.Collections.Generic;
using System.Text;

namespace SQLBuilderWPF
{
    class JSSyntaxProvider
    {
        static List<string> tags = new List<string>();
        static List<char> specials = new List<char>();
        static List<string> functions = new List<string>();

        #region ctor
        static JSSyntaxProvider()
        {
            string[] keywords = {
                "AND",
                "OR",
                "SELECT",
                "FROM",
                "WHERE"
            };
            tags = new List<string>(keywords);

            char[] chrs = {
                '.',
                ')',
                '(',
                '[',
                ']',
                '>',
                '<',
                ':',
                ';',
                '\n',
                '\t',
                ','
            };
            specials = new List<char>(chrs);

            string[] strsfunctions = {
                "ObjectInfo",
                "ObjectLen"
            };
            functions = new List<string>(strsfunctions);
        }
        #endregion
        public static List<char> GetSpecials
        {
            get { return specials; }
        }
        public static List<string> GetTags
        {
            get { return tags; }
        }
        public static bool IsKnownTag(string tag)
        {
            return tags.Exists(delegate(string s) { return s.ToLower().Equals(tag.ToLower()); });
        }

        public static bool IsFunction(string tag)
        {
            return functions.Exists(delegate(string s) { return s.ToLower().Equals(tag.ToLower()); });
        }

        public static bool IsSpecial(string tag)
        {
            return specials.Exists(delegate(char s) { return s.Equals(tag.ToLower()); });
        }
        public static List<string> GetJSProvider(string tag)
        {
            return tags.FindAll(delegate(string s) { return s.ToLower().StartsWith(tag.ToLower()); });
        }


    }
}
